Ternary 三元運算子


Posted by Rich on 2021-04-22

console.log(10 > 5 ? 'bigger' : 'smaller')
output:bigger

condition ? true : false
條件 ? true就執行 : false就執行


#note







Related Posts

React-[入門篇]-在JSX中加入inline style樣式 | 引入 external css 檔案

React-[入門篇]-在JSX中加入inline style樣式 | 引入 external css 檔案

JavaScript 網頁事件處理 2

JavaScript 網頁事件處理 2

[第九週]  PHP 與 MySQL 的互動:讀取資料

[第九週] PHP 與 MySQL 的互動:讀取資料


Comments